package cn.com.gzheroli.bfw.web.ws.test;

import org.apache.cxf.endpoint.Client;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;

/**
 * 
 * @ClassName: JeecgWServiceClient
 * @Description: cxf客户端测试类
 * @author huangzq
 * @date 2015-12-31 下午05:44:50
 * 
 */
public class JeecgWServiceClient {

	public static void main(String[] args) {
		JeecgWServiceClient cc=new JeecgWServiceClient();
		cc.rpcClient();
		cc.jaxClient();
	}
	public void jaxClient(){
		JaxWsProxyFactoryBean bean = new JaxWsProxyFactoryBean();
		bean.setServiceClass(JeecgWServiceI.class);
		bean.setAddress("http://localhost:8090/BFWWeb/cxf/JeecgWService");
		JeecgWServiceI client = (JeecgWServiceI) bean.create();
		System.out.println(client.sayHello());
	}
	public static void main11(String[] args) {
		JaxWsProxyFactoryBean bean = new JaxWsProxyFactoryBean();
		bean.setServiceClass(JeecgWServiceI.class);
		bean.setAddress("http://localhost:8090/BFWWeb/cxf/JeecgWDemoService");
		JeecgWServiceI client = (JeecgWServiceI) bean.create();
		System.out.println(client.sayHello());
	}
	
	public void rpcClient(){
		JaxWsDynamicClientFactory  factory =JaxWsDynamicClientFactory.newInstance();
	    Client client =factory.createClient("http://localhost:8090/BFWWeb/cxf/JeecgWDemoService?wsdl");
	    try {
	     Object[] obj =client.invoke("sayHello","xiao");
	  System.out.println("resp:"+obj[0]);
	 } catch (Exception e) {
	  // TODO Auto-generated catch block
	  e.printStackTrace();
	 }
	}
}
